package cn.edu.seig.textbook.service.impl;

import cn.edu.seig.textbook.domain.pojo.Students;
import cn.edu.seig.textbook.mapper.StudentsMapper;
import cn.edu.seig.textbook.service.IStudentsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author day
 * @since 2024-11-07
 */
@Service
public class StudentsServiceImpl extends ServiceImpl<StudentsMapper, Students> implements IStudentsService {
    @Autowired
    private StudentsMapper studentsMapper;

    @Override
    public List<Students> getStudentsByName(String name){
        return studentsMapper.getStudentsByName(name);
    }

    @Override
    public List<Students> getStudents() {
        return studentsMapper.selectList(null);
    }

    @Override
    public boolean addStudent(Students students) {
        return studentsMapper.insertOrUpdate(students);
    }

    @Override
    public Students getStudentById(String id) {
        return studentsMapper.selectById(id);
    }

    @Override
    public int deleteStudentById(String id) {
        return studentsMapper.deleteById(id);
    }

    @Override
    public Students getStudentByUserId(int userId) {
        return studentsMapper.selectById(userId);
    }


}
